package com.example.tester.service.impl;

import com.example.tester.dao.StudentDao;
import com.example.tester.entity.Student;
import com.example.tester.mapper.StudentMapper;
import com.example.tester.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author lzh
 * @date 2019/9/6 - 16:47
 */
@Service
public class StudentServiceImpl implements IStudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Autowired
    private StudentDao studentDao;


    @Override
    public Student addStudent(Student student) {
        studentDao.add(student);
        return studentMapper.queryStudentBySno(student.getSno());
    }

    @Override
    public Student update(Student student) {
        studentMapper.updateByPrimaryKeySelective(student);
        return this.studentMapper.queryStudentBySno(student.getSno());
    }

    @Override
    public void deleteStudentBySno(Integer sno) {
        studentMapper.deleteByPrimaryKey(sno);
    }

    @Override
    public Student queryStudentBySno(Integer sno) {
        return studentMapper.queryStudentBySno(sno);
    }
}
